package com.cmft.testlibrary

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.cmft.waltzpagemanager.IContainer
import com.cmft.waltzpagemanager.PageApp
import org.json.JSONObject

class TestContainer : IContainer {
    override fun getName(): String {
        return "Test"
    }

    override fun startPage(activity: Activity, pageId: String, param: Bundle?, requestCode: Int) {
        when (pageId) {
            "1" -> {
                val intent = Intent(activity, Test1Activity::class.java)
                param?.let {
                    intent.putExtras(it)
                }
                if (requestCode != -1) {
                    activity.startActivityForResult(intent, requestCode)
                } else {
                    activity.startActivity(intent)
                }
            }
            "2" -> {
                val intent = Intent(activity, Test2Activity::class.java)
                param?.let {
                    intent.putExtras(it)
                }
                if (requestCode != -1) {
                    activity.startActivityForResult(intent, requestCode)
                } else {
                    activity.startActivity(intent)
                }
            }
        }
    }

    override fun startPage(activity: Activity, pageApp: PageApp, param: Bundle?, requestCode: Int) {

    }

    override fun getPageFragment(pageId: String, param: Bundle?): Fragment {
        return when (pageId) {
            "3" -> {
                val fragment = TestFragment()
                fragment.arguments = param
                return fragment
            }
            else -> {
                DefFragment()
            }
        }
    }

    override fun getPageFragment(pageApp: PageApp, param: Bundle?): Fragment {
        TODO("Not yet implemented")
    }

    override fun didLogin(userInfo: JSONObject?) {
        TODO("Not yet implemented")
    }

    override fun userDidLogout() {
        TODO("Not yet implemented")
    }

    override fun infoDidChange(userInfo: JSONObject?) {
        TODO("Not yet implemented")
    }

    override fun didChangeCurrentProject(userInfo: JSONObject?) {
        TODO("Not yet implemented")
    }
}